<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>验收单</title>
    <meta name="decorator" content="default"/>
    <script src="${ctxStatic}/lodop/LodopFuncs.js" type="text/javascript"></script>
    <script>
        function exportExcel() {
                parent.$.jBox.confirm("确认要导出【验收单】吗？", "系统提示", function (v, h, f) {
                    if (v == "ok") {
                        $("#searchForm").attr("action", "${ctx}/book/purchase/export").submit();
                    }
                }, {buttonsFocus: 1});
                top.$('.jbox-body .jbox-icon').css('top', '55px');
        }
        function searchLedger() {
            $("#searchForm").attr("action", "${ctx}/book/purchase/purchaseLedger").submit();
        }
    </script>
</head>
<body>
<div>
    <form:form id="searchForm" action="${ctx}/book/purchase/purchaseLedger" method="post" class="breadcrumb form-search">
        <label>条形码范围：</label>
        <input name="begin" value="${begin}" type="text" maxlength="20" class="input-small"/>
        —&nbsp;<input name="end" value="${end}" type="text" maxlength="20" class="input-small"/>&nbsp;
        <label>批次：</label>
        <select name="batchId" style="width: 140px;">
            <option value="">请选择</option>
            <c:forEach items="${all}" var="batch">
                <option value="${batch.batchId}" ${batch.remarks}>${batch.batchNumber}</option>
            </c:forEach>
        </select>
        <a id="btnSubmit" href="javascript:void(0)" onclick="searchLedger()" class="btn">查询</a>&nbsp;&nbsp;
        <a id="btnPrint" href="javascript:void(0)" onclick="print()" class="btn">打印</a>&nbsp;&nbsp;
        <a id="btnExport" href="javascript:void(0)" onclick="exportExcel()" class="btn">导出Excel</a>
    </form:form>
    <div id="ledgerContent">
        <style type="text/css" scoped>
            .table-bordered th, .table-bordered td {  border-left: 1px solid #ddd;  }
            .table th, .table td {  line-height: 20px;  text-align: left;  border-top: 1px solid #ddd;  }
            .table-bordered {  border: 1px solid #ddd;  border-collapse: separate;  border-left: 0;  border-radius: 4px;  }
        </style>
        <div style="width: 1200px;">
            <div style="text-align: center">
                <h2>验收单</h2>
            </div>
            <div style="width: 100%;text-align: left;">
                【批号：${purchase.batchNumber}】
            </div>
            <c:set var="total" value="0"/>
            <c:set var="totalPrice" value="0"/>
            <table id="contentTable" style="width: 100%;" class="table table-striped table-bordered table-condensed">
                <tr>
                    <th>序号</th>
                    <th>验收日期</th>
                    <th>ISBN</th>
                    <th>题名</th>
                    <th>著者</th>
                    <th>索书号</th>
                    <th>册数</th>
                    <th>价格</th>
                    <th>总价</th>
                </tr>
                <c:forEach items="${generalledger}" var="r" varStatus="status">
                    <tr>
                        <td align="center" style="text-align:center;min-width: 50px;">${status.count}</td>
                        <td style="width:140px;"><fmt:formatDate value="${r.iptTme}" pattern="yyyy-MM-dd"/></td>
                        <td style="width:200px;">${r.isbn}</td>
                        <td style="width:450px;">${r.bookname}</td>
                        <td style="width:320px;">${r.author}</td>
                        <td style="width:120px;">${r.classcode}/${r.place}</td>
                        <td style="text-align:right;width:60px;">${r.amount}</td>
                        <td style="text-align:right;width:80px;"><fmt:formatNumber type="number" value="${r.price}" pattern="0.00" maxFractionDigits="2"/></td>
                        <td style="text-align:right;width:80px;"><fmt:formatNumber type="number" value="${r.price * r.amount}" pattern="0.00" maxFractionDigits="2"/></td>
                    </tr>
                </c:forEach>
                <tr>
                    <c:if test="${not empty generalledger}">
                        <td colspan="9" style="text-align:center;">由于数据太多，只显示100行</td>
                    </c:if>
                    <c:if test="${empty generalledger}">
                        <td colspan="9" style="text-align:center;">没有查询到数据</td>
                    </c:if>
                </tr>
                <tr>
                    <td colspan="6">合计：</td>
                    <td style="text-align:right;">${ledgerAmount.amount}</td>
                    <td></td>
                    <td style="text-align:right;">
                        <fmt:formatNumber type="number" value="${ledgerAmount.price}" pattern="#.00" maxFractionDigits="2"/>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
<object id="LODOP" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
    <param name="Border" value="1">
    <param name="Color" value="white">
    <embed id="LODOP_EM" TYPE="application/x-print-lodop" width=0 height=0 border=0 Color="white"
           PLUGINSPAGE="install_lodop.exe">
</object>
<script type="text/javascript">
    /**
     *  打印预览
     */
    //声明为全局变量
    var LODOP;
    function print() {
        LODOP = getLodop(document.getElementById('LODOP'), document.getElementById('LODOP_EM'));
        LODOP.PRINT_INIT("打印");
        LODOP.SET_PRINT_PAGESIZE(1, 0, 0, "A4");

        LODOP.ADD_PRINT_HTM(20, 20, 600, 800, $("#ledgerContent").html());
        LODOP.SET_PRINT_MODE("PRINT_PAGE_PERCENT","Full-Width");//按整页缩放

        LODOP.PRINT_DESIGN();
        LODOP.SHOW_CHART();
    }
</script>
</body>
</html>